package com.cxhc.system.service.app.impl;

import java.util.List;

import com.cxhc.system.domain.app.IntegralAfter;
import com.cxhc.system.mapper.SysUserMapper;
import com.cxhc.system.mapper.app.IntegralAfterMapper;
import com.cxhc.system.service.app.IIntegralAfterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 积分复议记录Service业务层处理
 *
 * @author Dhq
 * @date 2024-09-09
 */
@Service
public class IntegralAfterServiceImpl implements IIntegralAfterService {
    @Autowired
    private IntegralAfterMapper integralAfterMapper;
    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 查询积分复议记录列表
     *
     * @param integralAfter 积分复议记录
     * @return 积分复议记录
     */
    @Override
    public List<IntegralAfter> selectIntegralAfterList(IntegralAfter integralAfter) {
        return integralAfterMapper.selectIntegralAfterList(integralAfter);
    }

    /**
     * 新增积分复议记录
     *
     * @param integralAfter 积分复议记录
     * @return 结果
     */
    @Override
    public int insertIntegralAfter(IntegralAfter integralAfter) {
        integralAfter.setBalance(integralAfter.getBalance() + integralAfter.getIntegral());
        int row = integralAfterMapper.insertIntegralAfter(integralAfter);
        if (row > 0) {
            sysUserMapper.updateBalance(integralAfter.getUserId(), integralAfter.getBalance());
        }
        return row;
    }

}
